import request from "@/utils/request";
import {baseURLMulti} from "@/setting";
const baseURL=baseURLMulti

/**
 * 添加门票
 * @param data
 * @returns {*}
 */
export function addTicket(data){
    return request({
        baseURL,
        url:`/ticket/addTicket`,
        method:'post',
        data
    })
}

/**
 * 获取门票列表
 * @param page
 * @param limit
 * @returns {*}
 */
export function getTicket(page,limit){
    return request({
        baseURL,
        url:`/ticket/getTicketList/${page}/${limit}`,
        method:'get'
    })
}

export function getTickets(page,limit){
    return request({
        baseURL,
        url:`/ticket/getTicketListUser/${page}/${limit}`,
        method:'get'
    })
}

/**
 * 批量删除门票
 * @param page
 * @param limit
 * @returns {*}
 */
export function deleteTicketByIds(data){
    return request({
        baseURL,
        url:`/ticket/deleteTicket`,
        method:'delete',
        data
    })
}

/**
 * 通过id获取门票
 * @param id
 * @returns {*}
 */
export function getTicketById(id){
    return request({
        baseURL,
        url:`/ticket/getTicket/${id}`,
        method:'get'
    })
}

/**
 * 根据email或name查询票
 * @param data
 * @returns {*}
 */
export function searchTicketByEON(data,page,size){
    return request({
        baseURL,
        url:`/ticket/searchTicket/${data}/${page}/${size}`,
        method:'get'
    })
}

/**
 * 根据订单号查询票
 * @param id
 * @returns {*}
 */
export function searchTicketById(id){
    return request({
        baseURL,
        url:`/ticket/searchTicketOne/${id}`,
        method:'get'
    })
}

/**
 * 购票
 * @param data
 * @returns {*}
 */
export function createOrder(data){
    return request({
        baseURL,
        url:`/ticket/createOrder`,
        method:'post',
        data
    })
}

/**
 * 分页获取，用户购买的门票
 * @param userId
 * @param status
 * @param page
 * @param limit
 * @returns {*}
 */
export function getTicketListByUserId(userId,status,page,limit){
    return request({
        baseURL,
        url:`/userTicket/getTicketListByUserId/${userId}/${status}/${page}/${limit}`,
        method:'get'
    })
}

export function getTicketDetail(orderId){
    return request({
        baseURL,
        url:`/userTicket/getTicketDetail/${orderId}`,
        method:'get'
    })
}

/**
 * 更新门票状态
 * @param ticketId
 * @param status
 * @returns {*}
 */
export function updateStatus(ticketId,status){
    return request({
        baseURL,
        url:`/userTicket/updateStatus/${ticketId}/${status}`,
        method:'put'
    })
}

/**
 * 删除门票
 * @returns {*}
 */
export function deleteTicket(){
    return request({
        baseURL,
        url:`/userTicket/deleteTicket`,
        method:'delete'
    })
}

/**
 * 校准门票
 * @returns {*}
 */
export function calibrate(){
    return request({
        baseURL,
        url:`/userTicket/calibrate`,
        method:'get'
    })
}

/**
 * 退票
 * @returns {*}
 */
export function returnOneTicket(data){
    return request({
        baseURL,
        url:`/userTicket/returnTicket`,
        method:'delete',
        data
    })
}
